home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / metagifb / main32.bas < prev    next >
Encoding:
BASIC Source File  |  1996-06-06  |  3.7 KB  |  111 lines

  1. Attribute VB_Name = "basMAIN"
  2. Option Explicit
  3. '  MetaGif converts Windows Metafiles to CompuServe Gif files. This
  4. '  32 bit DLL allows image resizeing without distortion. With this
  5. '  library you can create WEB documents on the fly, from your Windows
  6. '  application. With MetaGif you can create a Gif file that is larger
  7. '  than the screen.
  8. '
  9. '  The main() program is a simple example of how to use MetaGif. The program
  10. '  will convert the two Windows (placeable) Metafiles to CompuServe Gif
  11. '  files. You can use Microsoft Word to view the metafiles and the gif file
  12. '  results.
  13. '
  14. '  See the MetaGif function declaration for a full description of usage.  MetaGif
  15. '  is a Shareware program, see the readme.txt file for registration
  16. '  information.
  17. '
  18. '  THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
  19. '  OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
  20. '  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  21. '  PARTICULAR PURPOSE.
  22. '
  23. '  Author:
  24. '     David E. Suffield
  25. '     Eckler Software
  26. '     620 101st Court
  27. '     Vancouver, WA 98664
  28. '     dsuffiel@worldaccess.com
  29. '
  30. Declare Function LoadLibrary Lib "Kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
  31. Declare Function FreeLibrary Lib "Kernel32" (ByVal hLibModule As Long) As Long
  32.  
  33. ' Function: MetaGif()
  34. '
  35. ' Purpose: Convert Placeable Metafiles to Gif files.
  36. '
  37. ' Parameters:
  38. '          szWmf    placeable metafile file name (input)
  39. '          szGif    gif file name (output)
  40. '          scaleX   scale factor percentage (100 = width*1)
  41. '          scaleY   scale factor percentage (150 = height*1.5)
  42. '
  43. ' Returns:
  44. '          -3    could not open placeable metafile
  45. '          -2    could not write gif file
  46. '          -1    not a placeable metafile
  47. '           0    not enough memory
  48. '           1    ok
  49. '
  50. ' History:
  51. '           1.00 Converted from 16 bit MetaGif.
  52. '
  53. '           2.00 Rewritten for 32 bit WIN95/NT OS.  Up to 32 times faster than
  54. '           MetaGif 1.00.  MetaGif 2.00 supports the following display modes -
  55. '           1, 4, 8, 16 and 24 color bits per pixel.  This corresponds to
  56. '           monochrome, 16, 256, 32k and 16meg color displays.  MetaGif memory
  57. '           usage depends on the size of your gif file in pixels and your default
  58. '           color display settings.  A 24 bit color display would use 3 times
  59. '           more memory than a 8 bit color display.
  60. '
  61. Declare Function MetaGif Lib "metagif32.dll" (ByVal szWmf As String, ByVal szGif As String, ByVal scaleX As Integer, ByVal scaleY As Integer) As Long
  62.  
  63. Global stopit As Integer
  64.  
  65. Sub main()
  66.    Dim r As Integer, i As Integer, hInst As Long
  67.    Dim exePath As String
  68.    Dim t1 As Long, t2 As Long
  69.      
  70.    t1 = Timer
  71.    Screen.MousePointer = 11   ' Change pointer to hourglass.
  72.    
  73.    frmTest.txtMax = 10
  74.    frmTest.txtCnt = 0
  75.    frmTest.Show
  76.    frmTest.Refresh
  77.  
  78.    If (Right$(App.Path, 1) <> "\") Then
  79.       exePath = App.Path + "\"
  80.    Else
  81.       exePath = App.Path   'probably app.path="A:\"
  82.    End If
  83.  
  84.    stopit = False
  85.    
  86.    For i = 1 To frmTest.txtMax
  87.       'Convert metafile to gif file, output is 50% bigger.
  88.       r = MetaGif(exePath + "anchor.wmf", exePath + "anchor.gif", 150, 150)
  89.       If (r <> 1) Then
  90.          MsgBox ("MetaGif() return: " + Format$(r))
  91.       End If
  92.       
  93.       'Convert metafile to gif file, output is 50% smaller.
  94.       r = MetaGif(exePath + "coins.wmf", exePath + "coins.gif", 50, 50)
  95.       If (r <> 1) Then
  96.          MsgBox ("MetaGif() return: " + Format$(r))
  97.       End If
  98.       
  99.       frmTest.txtCnt = i
  100.       r = DoEvents()
  101.       If (stopit) Then Exit For
  102.    Next
  103.    
  104.    Unload frmTest
  105.    Screen.MousePointer = 0
  106.    t2 = Timer - t1
  107.    MsgBox ("time in seconds: " + Format$(t2))
  108.  
  109. End Sub
  110.  
  111.